var currentVaiTro=0;
var currentIndex=0;
var currentMaCH=maCH;
var currentVaiTro=0;
var soLuong = soLuongBLND;
function loadBinhLuan(maCH, vaiTro) {
	$.ajax({
		url:"binhluan.php",
		data: {maCH: maCH,
			vaiTro: vaiTro,
			index: 0,
			number: 2},
		success: function(data){
			$("#content").html(data);
			currentVaiTro = vaiTro;
			currentIndex = 0;
			if(vaiTro==0){
				soLuong = soLuongBLND;
				document.getElementById("li-nd").style.backgroundColor="#009999";
				document.getElementById("li-cg").style.backgroundColor="#003366";
			}else if(vaiTro==1){
				soLuong = soLuongBLCG;
				document.getElementById("li-nd").style.backgroundColor="#003366";
				document.getElementById("li-cg").style.backgroundColor="#009999";
			}			
		},
		error: function(xhr, status){
			alert("Sorry, there was a problem!");
		},
		complete: function( xhr, status ){
			
		}
	});
}

$(document).scroll(function(){
	if ($(window).scrollTop() + $(window).height() == $(document).height()){
		currentIndex += 2;
		if(currentIndex < soLuong){
			$.ajax({
				url:"binhluan.php",
				data: {maCH: maCH,
					vaiTro: currentVaiTro,
					index: currentIndex,
					number: 2},
				success: function(data){
					var oldData = document.getElementById('content').innerHTML + data;
					$("#content").html(oldData);						
				},
				error: function(xhr, status){
					alert("Sorry, there was a problem!");
				},
				complete: function( xhr, status ){
					
				}
			});
		}
	}
});